package LeetCode;

import java.util.Random;

public class LC_384_ShuffleanArray {

    public static void main(String[] args) {

    }

    public class Solution {

        private int[] orgn;
        private int[] cur;

        public Solution(int[] nums) {
            orgn = nums;
        }

        public int[] reset() {
            return orgn;
        }

        public int[] shuffle() {
            int len = orgn.length;
            cur = new int[len];
            System.arraycopy(orgn, 0, cur, 0, len);
            int pos;
            int temp;
            Random ran = new Random();
            for (int i = len - 1; i >= 0; i--) {
                pos = ran.nextInt(i + 1);
                temp = cur[pos];
                cur[pos] = cur[i];
                cur[i] = temp;
            }
            return cur;
        }

    }
}